package com.fc.authentication.common.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * Created by futurecreative on 2018/2/7.
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Result<T> {

    private boolean success = true;

    private String errorCode;

    private String msg;

    private T data;

    public static Result error(String errorCode, String message) {
        Result error = new Result();
        error.setSuccess(false);
        error.setErrorCode(errorCode);
        error.setMsg(message);

        return error;
    }

    public static <T> Result<T> ok(T data) {
        Result success = new Result();
        success.setData(data);

        return success;
    }

    public static Result ok() {
        Result success = new Result();
        return success;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
